# Maintainer: Laurent Carlier <lordheavym@gmail.com>

pkgname=spirv-tools
pkgver=2022.4
pkgrel=1
pkgdesc="API and commands for processing SPIR-V modules"
arch=('x86_64')
url="https://www.khronos.org/vulkan/"
license=('custom')
groups=(vulkan-devel)
depends=('gcc-libs' 'sh')
makedepends=('cmake' 'python' 'git' 'ninja' 'spirv-headers')
source=("git+https://github.com/KhronosGroup/SPIRV-Tools.git#tag=v${pkgver}")
sha256sums=('SKIP')

build() {
  cd SPIRV-Tools

  cmake \
      -Bbuild \
      -GNinja \
      -DCMAKE_INSTALL_PREFIX=/usr \
      -DCMAKE_INSTALL_LIBDIR=lib \
      -DCMAKE_BUILD_TYPE=None \
      -DSPIRV_WERROR=Off \
      -DBUILD_SHARED_LIBS=ON \
      -DSPIRV_TOOLS_BUILD_STATIC=OFF \
      -DSPIRV-Headers_SOURCE_DIR=/usr
  ninja -C build
}

check() {
  cd SPIRV-Tools
  ninja -C build test
}

package() {
  cd SPIRV-Tools

  DESTDIR="${pkgdir}" ninja -C build install

  install -Dm644 LICENSE "${pkgdir}"/usr/share/licenses/${pkgname}/LICENSE
}
